package com.gzy.mylog;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.gzy.mylog.manager.AuthManager;
import com.gzy.mylog.utils.SPUtils;

import java.util.TimeZone;

public class LaunchActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);

//        TimeZone tz = TimeZone.getDefault();
//        TimeZone china = TimeZone.getTimeZone("GMT+:08:00");
        // TimeZone.getTimeZone("ETC/GMT-8")
        initUI();

        runOnUiThread(this::doLogin,1500);
    }

    private void doLogin() {
        if (AuthManager.isLogin(this)){ //判断是否登录
          // 已登录 进入 主界面
            startActivity(new Intent(this,MainActivity.class));
        }else{
          // 进入 登录页面
            startActivity(new Intent(this,LoginActivity.class));
        }



        runOnUiThread(this::finish,300);
//        runOnUiThread(new Runnable() {
//            @Override
//            public void run() {
//                finish();
//            }
//        },1500);
    }

    private void initUI() {
        String versionName = BuildConfig.VERSION_NAME;
        TextView view = (TextView)findViewById(R.id.tv_version);
        view.setText(versionName);
    }
}
